package leetcode;




import org.jetbrains.annotations.NotNull;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;

/**
 * create by duanx 2022/2/7
 *@classname: Test3
 *@author: duanx
 *@date: 2022/2/7 9:22
 **/
public class Test7 {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str;
            while (!(str = reader.readLine()).isEmpty()){
                str = str.toUpperCase();
                int n = countWhile(str.length());
                Map<Character, Integer> map = countChar(str);
                int m=1;
                for(Map.Entry<Character, Integer> entry : map.entrySet()){
                    int value = entry.getValue();
                    m=m* countWhile(value);
                }
                System.out.println(n/m);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    /**
     * 1.递归处理阶乘
     * @param n 阶乘数
     * @return 阶乘结果
     */
    private static int countRecursion(int n){
        if(n<0){
            return -1;
        }
        if(n==0){
            return 1;
        }else if(n==1){
            return 1;
        }else{
            return n* countRecursion(n-1);
        }
    }
    /**
     * 2.循环处理阶乘
     * @param n 阶乘数
     * @return 阶乘结果
     */
    private static int countWhile(int n){
        int result = 1;
        if (n==0){
            return result;
        }
        if (n<0){
            return -1;
        }
        int i = 1;
        while (i<=n){
            result = result*i;
            i++;
        }
        return result;
    }



    /**
     * 统计每个字母出现次数
     * @param str 字符串
     * @return 字母出现次数
     */
    @NotNull
    private static Map<Character , Integer> countChar(@NotNull String str) {
        Map<Character, Integer> map = new HashMap<>(10);
        char[] chars = str.toCharArray();
        TreeSet<Character> characters = new TreeSet<>();
        for (char aChar : chars) {
            characters.add(aChar);
        }
        for (char c : characters) {
            int count = 0;
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == c) {
                    count++;
                }
            }
            map.put(c, count);
        }
        return map;
    }
}
